'use strict';

const express = require('express');
const dbutility = require('../../common/dbutility');
const gputility = require('../../common/gputility');
const logger = require('../../common/logutility').logger('admIndex');
let router = express.Router();

router.get('/', function(req, res, next) {
    gputility.excuteGP(getGP(req, res));
});

function* getGP(req, res) {
    try {
        let doc = yield dbutility.couModel.getCouAll();
        res.render('./adm/admIndex', { couCount: doc.length });
    } catch (e) {
        logger.error(e);
        res.redirect('/error');
    }
}

module.exports = router;